
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>后台管理系统</title>
<meta name="author" content="DeathGhost" />
<link rel="stylesheet" type="text/css" href="/admin/styles/style.css" />
<script type="text/javascript" src="/admin/js/jquery.1.12.js"></script>
<script type="text/javascript" src="/admin/js/jquery.js"></script>
<script src="/admin/js/jquery.mCustomScrollbar.concat.min.js"></script>
</head>
<body>
<!--header-->
    <h2><strong style="color:grey;">货品列表</strong></h2>
    <div class="page_title">
        <!-- <h2 class="fl">货品列表</h2> -->
        <a class="fr top_rt_btn"  id="showPopTxt" href="javascript: void(0)">添加货品</a>
    </div>
    <table class="table">
        <tr>
            <?php foreach ($specList as $attrTH): ?>
                <th><?= $attrTH['attr_name'] ?></th>
            <?php endforeach; ?>
            <th>库存</th>
            <th>操作</th>
        </tr>
        <?php foreach ($product as $info): ?>
            <tr align="center">
                <?php foreach ($info['product_attr'] as $attrValue): ?>
                    <td><?= $attrValue ?></td>
                <?php endforeach; ?>
                <td><?= $info['product_number'] ?></td>
                <td><a href="">操作</a></td>
            </tr>
        <?php endforeach; ?>
    </table>
    <aside class="paging">
    </aside>
</section>
<section class="pop_bg">
    <div class="pop_cont">
        <!--title-->
        <h3>货品组合</h3>
        <!--content-->
        <form action="" id="product_form">
            <input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
            <input type="hidden" name="goods_id" value="<?= $goods_id ?>" />
            <div class="pop_cont_input">
                <ul>
                    <?php foreach ($specList as $attr): ?>
                        <li>
                            <span class="ttl" style="width:55px;"><?= $attr['attr_name'] ?></span>
                            <select class="select" name="product_attr[]">
                                <?php foreach ($attr['attr_list'] as $spec): ?>
                                    <option value="<?= $spec['goods_attr_id'] ?>"><?= $spec['attr_value'] ?></option>
                                <?php endforeach; ?>
                            </select>
                        </li>
                    <?php endforeach; ?>
                    <li>
                        <span  style="width:80px;">货品数量</span>
                        <input type="text" name="product_number" value="100" placeholder="货品数量..." class="textbox"/>
                    </li>
                </ul>
            </div>
        </form>
        <div class="btm_btn">
            <input type="button" value="确认" class="input_btn trueBtn"/>
            <input type="button" value="关闭" class="input_btn falseBtn"/>
        </div>
    </div>
 </div>
</section>
</body>
</html>
<!--结束：弹出框效果-->
<script>
    $(document).ready(function () {
        //弹出文本性提示框
        $("#showPopTxt").click(function () {
            $(".pop_bg").fadeIn();
        });
        //弹出：确认按钮
        $(".trueBtn").click(function () {
            var formData = $('#product_form').serialize();
            $.ajax({
                type: 'post',
                url: 'http://www.nbshop.com/admin/product_add',
                data: formData,
                dataType: 'json',
                success: function (result) {
                    //alert(result);
                    if (result == 0) {
                        alert('组合货品失败');
                       // return false;
                    }
                    alert('组合货品成功');
                    location.reload();
                   // location.href = 'product_list';
                }
            });
        });
        //弹出：取消或关闭按钮
        $(".falseBtn").click(function () {
            $(".pop_bg").fadeOut();
        });
    });
</script>